package com.ruoyi.web.controller.business;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TSmjOrderInfo;
import com.ruoyi.business.service.ITSmjOrderInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 售卖机订单信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-02
 */
@Controller
@RequestMapping("/business/tSmjOrderInfo")
public class TSmjOrderInfoController extends BaseController
{
    private String prefix = "business/tSmjOrderInfo";

    @Autowired
    private ITSmjOrderInfoService tSmjOrderInfoService;

    @RequiresPermissions("business:tSmjOrderInfo:view")
    @GetMapping()
    public String tSmjOrderInfo()
    {
        return prefix + "/tSmjOrderInfo";
    }

    /**
     * 查询售卖机订单信息列表
     */
    @RequiresPermissions("business:tSmjOrderInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSmjOrderInfo tSmjOrderInfo)
    {
        startPage();
        List<TSmjOrderInfo> list = tSmjOrderInfoService.selectTSmjOrderInfoList(tSmjOrderInfo);
        return getDataTable(list);
    }

    /**
     * 导出售卖机订单信息列表
     */
    @RequiresPermissions("business:tSmjOrderInfo:export")
    @Log(title = "售卖机订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSmjOrderInfo tSmjOrderInfo)
    {
        List<TSmjOrderInfo> list = tSmjOrderInfoService.selectTSmjOrderInfoList(tSmjOrderInfo);
        ExcelUtil<TSmjOrderInfo> util = new ExcelUtil<TSmjOrderInfo>(TSmjOrderInfo.class);
        return util.exportExcel(list, "售卖机订单信息数据");
    }

    /**
     * 新增售卖机订单信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存售卖机订单信息
     */
    @RequiresPermissions("business:tSmjOrderInfo:add")
    @Log(title = "售卖机订单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSmjOrderInfo tSmjOrderInfo)
    {
        return toAjax(tSmjOrderInfoService.insertTSmjOrderInfo(tSmjOrderInfo));
    }

    /**
     * 修改售卖机订单信息
     */
    @RequiresPermissions("business:tSmjOrderInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TSmjOrderInfo tSmjOrderInfo = tSmjOrderInfoService.selectTSmjOrderInfoById(id);
        mmap.put("tSmjOrderInfo", tSmjOrderInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存售卖机订单信息
     */
    @RequiresPermissions("business:tSmjOrderInfo:edit")
    @Log(title = "售卖机订单信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSmjOrderInfo tSmjOrderInfo)
    {
        return toAjax(tSmjOrderInfoService.updateTSmjOrderInfo(tSmjOrderInfo));
    }

    /**
     * 删除售卖机订单信息
     */
    @RequiresPermissions("business:tSmjOrderInfo:remove")
    @Log(title = "售卖机订单信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSmjOrderInfoService.deleteTSmjOrderInfoByIds(ids));
    }
}
